home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-08-22 | 2.2 KB | 44 lines | [TEXT/GEOL] |
- Item 7409264 21-July-89 14:17
-
- From: D2605 Xanadu Operating,Marc Stiegler, PRT
-
- To: MACAPP.TECH$ MACAPP Tech
-
- cc: FRIEDRICH1 Friedrich, Steve
- BURBECK.S Burbeck, Steve
- MACAPP.TEST MacApp SQA Team
-
- Sub: Inappropriate use of FailNIL
-
- MacApper's
- I recently found a (very) minor bug, but one that got me to thinking a bit
- about how errors are handled during development (vs released application). The
- bug was that I had managed to build a bad version of my application that didn't
- contain cmnu resources 128 or 129. When I ran it, MacApp alerted me that the
- application ran out of memory.
- After spending a while (hour-ish) tracking this down, I noticed that the
- initialization code was using FailNIL after getResource to decide if it could
- continue. In this case, since the resources were missing, it failed, reporting
- lack of memory.
- I have also used the FailNIL trick (in place of ASSERTs), so it surely IS
- useful. It is not quite the same as an ASSERT, however, because the test
- should remain in the production code. Assertion doesn't do anything if qDebug
- is false, so it's not a reasonable replacement in this case.
- I think the appropriate thing to do is to add a
- FailNILError( ptr: UNIV PTR; msg: LONGINT );
- routine, and replace FailNIL's that are being used as asserts. The msg
- would be used to present an appropriate error (like for not finding a resource
- use "Internal Program Error: Resource not found") rather than out of memory. A
- few "standard" errors (such as the one above) could be provided. It would make
- it bit easier to debug during development, and would also produce a more
- correct message in a release application, allowing a tech support person a
- better chance of deciding what's wrong. (I can just see some inexperienced
- people ResEdit'ing applications and accidently deleting resources...)
- I've added the routine to my library, but I think it's useful in general,
- and if added, should be used in those places FailNIL is now (inappropriately)
- used.
- comments?
- --Hugh Hoover
- Xanadu Operating Company
-
-